home *** CD-ROM | disk | FTP | other *** search
/ Acorn Risc Technologies StrongARM CD-ROM / Acorn Risc Technologies StrongARM CD-ROM.iso / ftp / documents / strongarm / sasupport < prev   
Encoding:
Text File  |  1996-07-30  |  13.9 KB  |  411 lines

  1. This note describes the new or revised SWIs in the StrongARM-aware version
  2. of RISC OS, and gives some guidance on use.
  3.  
  4.  
  5.                           CHANGES TO EXISTING SWIS
  6.                           ========================
  7.                        
  8. OS_MMUControl (page 5a-70)
  9. --------------------------
  10.  
  11.     This SWI has a new reason code, to support platform independent cache
  12.     and/or TLB flushing:
  13.  
  14. OS_MMUControl 1 (SWI &6B)
  15. -------------------------
  16.  
  17.     Cache flush request
  18.     
  19. On entry
  20.     R0 = reason code and flags
  21.            bits 0-7  = 1 (reason code)
  22.            bits 8-28 reserved (must be zero)
  23.            bit 29 set if flush of single entry, else complete flush
  24.            bit 30 set if processor TLBs are to be flushed
  25.            bit 31 set if processor caches are to be flushed
  26.     R1 = logical address, if R0 bit 29 set
  27.  
  28. On exit
  29.     R0,R1 preserved
  30.  
  31. Interrupts
  32.     Interrupt status is not altered
  33.     Fast interrupts are enabled
  34.  
  35. Processor mode
  36.     Processor is in SVC mode
  37.  
  38. Re-entrancy
  39.     SWI is not re-entrant
  40.     
  41. Use
  42.     This call implements platform independent cache and/or TLB flushing.
  43.     
  44.     WARNING: This SWI reason code is only intended for occasional, unavoidable
  45.              requirements for cache/TLB flushing. You should respect the
  46.              performance implications of this SWI reason code, in a similar
  47.              way to SWI OS_SynchroniseCodeAreas.
  48.              
  49.     Currently, bit 29 is ignored, so that only whole flushing of caches
  50.     and/or TLBs are supported. A cache will be cleaned before flushing,
  51.     where the processor supports a write-back cache.
  52.  
  53.     This reason code is not re-entrant. Interrupts are not disabled during
  54.     the flush, so the cache or TLB flush can only be considered to be complete
  55.     with respect to logical addresses that are not currently involved in
  56.     interrupts.
  57.  
  58.  
  59. OS_File 12, 14, 16 and 255 (page 2-40)
  60. --------------------------------------
  61. If R3 bit 31 is set on entry, the file being loaded will be treated as code,
  62. and the relevant area will be synchronised using OS_SynchroniseCodeAreas if
  63. necessary.
  64.  
  65. A filetype for Code (&F95) has been allocated, with the intention that it
  66. be a parallel of Data (&FFD), and when it is loaded a synchronise is
  67. automatically performed. However this functionality has _not_ been implemented
  68. in RISC OS 3.70; you will still need to set bit 31 as described above.
  69.  
  70.  
  71. DMA (page 5a-83)
  72. ----------------
  73. The DMA Manager now marks pages uncacheable for both transfers from device
  74. to memory and transfers from memory to device. This is to ensure StrongARM's
  75. write-back cache is cleaned before the transfer starts.
  76.  
  77.  
  78.  
  79.                              NEW SERVICE CALLS
  80.                              =================
  81.  
  82. Service_UKCompression (Service call &B7)
  83. ----------------------------------------
  84.  
  85.     An application that may need unsqueezing/patching has just been loaded
  86.     
  87. On entry
  88.     R0 = subreason code
  89.            0 -> first pass (unsqueeze)
  90.            1 -> second pass (patch)
  91.            all other codes reserved
  92.     R1 = &B7 (reason code)
  93.     R2 = load address
  94.     R3 = size
  95.     R4 = execute address
  96.     R5 = filename (as passed to FileSwitch, not canonicalised)
  97.  
  98. On exit
  99.     R1 preserved to pass on, or 0 to claim if you know you have performed
  100.     all required unsqueezeing/patching for this pass.
  101.     R3 may be modified to indicate an altered size (eg after unsqueezing)
  102.     R4 may be modified to specify an new execute address
  103.     Other registers preserved
  104.  
  105. Use
  106.     This service call is passed around when an Absolute (&FF8) file is run.
  107.     The sequence of events is as follows.
  108.     
  109.       1) The image is loaded.
  110.       2) If it does not contain an unsqueezed AIF header, then
  111.          Service_UKCompression 0 is issued.
  112.       3) Service_UKCompression 1 is issued.
  113.       4) OS_SynchroniseCodeAreas is called.
  114.     
  115.     Therefore unsqueezers and patchers need not do any synchronisation
  116.     except that necessary for their internal working (they may want to alter
  117.     some code, synchronise, and call it before returning from the service
  118.     call).
  119.     
  120.     Two modules are supplied with RISC OS 3.7 that use this service call:
  121.     
  122.         UnsqueezeAIF will unsqueeze squeezed AIF images on the first pass, and
  123.         squeezed non-AIF images by code modification (so the unsqueeze will
  124.         not occur until after stage 5 above)
  125.     
  126.         AppPatcher will patch squeezed and unsqueezed AIF images containing
  127.         certain common code sequences that are known to fail on StrongARM.
  128.  
  129.     Scanning an application for code sequences is a relatively slow operation.
  130.     Therefore a bit has been allocated in the AIF header to indicate that
  131.     a program is "StrongARM-ready". If bit 31 of the 13th word of the AIF
  132.     header (ie bit 31 of location &8030 in the loaded image) is set, the
  133.     patching stage will be skipped (in RISC OS 3.7 by AppPatcher claiming
  134.     the service call and doing nothing; in a future version of RISC OS
  135.     FileSwitch may not issue the service call). The program will still be
  136.     automatically unsqueezed; it is recommended that you continue to use the
  137.     existing Squeeze utility provided with Acorn C/C++, and rely on the
  138.     operating system to unsqueeze the image for you.
  139.    
  140.    
  141. Service_ModulePreInit (Service call &B9)
  142. ----------------------------------------
  143.  
  144.     A module is about to be initialised
  145.     
  146. On entry
  147.     R0 = module address
  148.     R1 = &B9 (reason code)
  149.     R2 = module length
  150.  
  151. On exit
  152.     R1 preserved to pass on
  153.  
  154. Use
  155.     This service is called just before a module is initialised. When a
  156.     module is *RMLoaded:
  157.     
  158.        1) The module is loaded into memory
  159.        2) The module is unsqueezed if necessary
  160.        3) Service_ModulePreInit is called
  161.        4) OS_SynchroniseCodeAreas is called
  162.     
  163.     This service call is intended to allow run-time patching of modules.
  164.     
  165.     
  166.                                   NEW SWIS
  167.                                   ========
  168.  
  169. OS_PlatformFeatures (SWI &6D)
  170. -----------------------------
  171.  
  172.     Determine various features of the host platform
  173.  
  174. On entry
  175.     R0 = reason code (bits 0-15) and flags (bits 16-31, reason code specific)
  176.     Other registers depend upon the reason code
  177.  
  178. On exit
  179.     Registers depend upon the reason code
  180.  
  181. Interrupts
  182.     Interrupt status is unaltered
  183.     Fast interrupts are enabled
  184.     
  185. Processor mode
  186.     Processor is in SVC mode
  187.  
  188. Re-entrancy
  189.     SWI is re-entrant
  190.  
  191. Use
  192.     This new SWI is used to determine various feaures of the platform that the
  193.     application or module is running on.
  194.  
  195.     The particular action of OS_PlatformFeatures is given by the reason code in
  196.     bits 0-15 of R0 as follows:
  197.     
  198.         R0    Action
  199.         0     Read code features
  200.  
  201.  
  202. OS_PlatformFeatures 0 (SWI &6D)
  203. -------------------------------
  204.  
  205.     Read code features
  206.  
  207. On entry
  208.     R0 = 0 (reason code); all flags are reserved, so bits 16-31 must be clear
  209.  
  210. On exit
  211.     R0 = bit mask of features:
  212.            Bits     Meaning
  213.            0        Must tell OS when code areas change (by calling
  214.                     OS_SynchroniseCodeAreas)
  215.            1        Enabling, then immediately disabling interrupts will _not_
  216.                     give interrupts a chance to occur
  217.            2        Must be in 32 bit mode to read hardware vectors
  218.            3        Storing PC to memory (eg with STR or STM) stores PC+8
  219.                     rather than PC+12
  220.            4        Data aborts occur with 'full early' timing (ie. as defined
  221.                     by ARM architecture 4)
  222.                                 
  223.    If bit 1 of R0 set then                             
  224.      R1 -> routine to call (with BL) between IRQ enable & disable.
  225.  
  226. Use
  227.     This call determines features of the host processor's instruction set.
  228.     
  229.     Platforms running ARM 6 or 7 cores will return with R0 bits 0-4 clear;
  230.     platforms running StrongARM will return with bits 0-4 set. For
  231.     compatibility with older versions of RISC OS, you should call this SWI in
  232.     the X form; if V is set on return and the error is 'SWI not known', then
  233.     this can be taken as equivalent to a return with R0 bits 0-4 clear. Note
  234.     that the easiest way to deal with the PC+8/PC+12 issue across all
  235.     platforms is to make sure that the code is valid in either case (typically
  236.     with judicious use of NOPs).
  237.     
  238.     The routine pointed to by R1 is suitable for calling from any 26-bit mode;
  239.     it preserves all flags and registers, and is reentrant.
  240.  
  241.  
  242. OS_SynchroniseCodeAreas (SWI &6E)
  243. ---------------------------------
  244.  
  245.     Inform the OS that code has been altered
  246.  
  247. On entry
  248.     R0 = flags
  249.            bit 0 clear  Entire address space to be synchronised.
  250.            bit 0 set    Address range to be synchronised.
  251.            bits 1-31    Reserved
  252.  
  253.     If R0 bit 0 is set then:
  254.         R1 = low address of range (word aligned)
  255.         R2 = high address (word aligned, _inclusive_)
  256.  
  257. On exit
  258.     R0-R2 preserved
  259.  
  260. Interrupts
  261.     Interrupt status is not altered
  262.     Fast interrupts are enabled
  263.  
  264. Processor mode
  265.     Processor is in SVC mode
  266.  
  267. Re-entrancy
  268.     SWI is not re-entrant
  269.  
  270. Use
  271.     This new SWI informs the OS that code has been newly generated or
  272.     modified in memory, before any attempt is made to execute the code.
  273.  
  274.     WARNING: This SWI is only intended for synchronisation with unavoidable
  275.              use of dynamic code, because of the potential for large
  276.              performance penalties. There is no longer any justification in
  277.              RISC OS applications for frequent code modification. This call
  278.              must never be used in an interrupt routine. Examples of
  279.              reasonable use include one-off loading, relocation etc. of
  280.              subsidiary code or libraries.
  281.      
  282.     When using this SWI, you should use the ranged variant wherever possible,
  283.     in order to minimise the performance penalty.
  284.     
  285.     The call may take a long time to return (up to around 0.5ms), so it should
  286.     not be called with interrupts disabled.
  287.  
  288.     For compatibility with older versions of RISC OS, you should either have
  289.     determined (with OS_PlatformFeatures) that this SWI should not be called,
  290.     or always call this SWI in the X form, and ignore any error returned. On
  291.     platforms that do not require code synchronisation (as indicated by
  292.     OS_PlatformFeatures 0), OS_SynchroniseCodeAreas will do nothing.
  293.  
  294.     Note that standard loading of applications or modules (and the standard C
  295.     overlay system) are automatically handled by the OS, and do not require
  296.     synchronisation. This may be defeated by custom squeezing, failure to use
  297.     a standard AIF header for applications, and so on.
  298.  
  299.  
  300. OS_CallASWI (SWI &6F)
  301. ---------------------
  302.  
  303.     Call a run-time determined SWI
  304.  
  305. On entry
  306.     R0-R9 as required for target SWI
  307.     R10 = target SWI number
  308.  
  309. On exit
  310.     R0-R9 as defined by target SWI
  311.     R10 preserved
  312.  
  313. Interrupt status
  314.    As defined by target SWI
  315.  
  316. Processor mode
  317.    As defined by target SWI
  318.  
  319. Re-entrancy
  320.    As defined by target SWI
  321.  
  322. Use
  323.     This new SWI allows a target SWI number to be determined at run time, and
  324.     passed in a register. This removes the need for a common idiom of
  325.     dynamic code, in language library SWI veneers for example. In an APCS-R
  326.     library, OS_CallASWIR12 may be more appropriate (see below).
  327.  
  328.     Note that OS_CallASWI is merely an alias for calling the target SWI.
  329.     It has no entry/exit conditions of its own, except for the special
  330.     use of R10. To call a target SWI with X bit set, us the X form of
  331.     the SWI number in R10; there is no distinction between OS_CallASWI
  332.     and XOS_CallASWI.
  333.  
  334.     You cannot call OS_CallASWI or OS_CallASWIR12 via OS_CallASWI, since there
  335.     is no defined final target SWI in this case.
  336.  
  337.     You cannot usefully call OS_BreakPt or OS_CallAVector using OS_CallASWI,
  338.     as OS_CallASWI will corrupt the processor flags before entering the
  339.     target SWI.
  340.     
  341.     For future compatibility, you should always use this SWI in preference
  342.     to any local construction for calling a SWI by number. For compatibility
  343.     with older versions of RISC OS, a new CallASWI module will be made available
  344.     (see below).
  345.     
  346.     Note that this SWI calling mechanism is almost certainly faster than
  347.     any other alternative implementation, including the original _kernel_swi
  348.     and _swix code contained in older versions of the SharedCLibrary. The
  349.     new SharedCLibrary now simply uses OS_CallASWIR12 for _kernel_swi and
  350.     _swix.
  351.     
  352.     OS_CallASWI cannot be called from BASIC as BASIC only passes registers
  353.     R0-R7 via its SYS instruction. It would not be useful anyway.
  354.  
  355.  
  356. OS_AMBControl (SWI &70)
  357. -----------------------
  358.  
  359.     This SWI is for system use only; you must not use it in your own code.
  360.  
  361.  
  362. OS_CallASWIR12 (SWI &71)
  363. ------------------------
  364.  
  365.     Call a run-time determined SWI
  366.  
  367. On entry
  368.     R0-R9 as required for target SWI
  369.     R12 = target SWI number
  370.  
  371. On exit
  372.     R0-R9 as defined by target SWI
  373.     R12 preserved
  374.  
  375. Interrupt status
  376.    As defined by target SWI
  377.  
  378. Processor mode
  379.    As defined by target SWI
  380.  
  381. Re-entrancy
  382.    As defined by target SWI
  383.  
  384. Use
  385.     This call is identical to OS_CallASWI, except that it uses R12 to specify
  386.     the target SWI. This may be more convenient in some environments. In
  387.     particular under APCS-R, R10 is the stack limit pointer, which must be
  388.     preserved at all times; if a SWI called using OS_CallASWI were to abort
  389.     or generate an error the run-time library would usually examine R10
  390.     and decide that it had no stack to handle the abort or error. Therefore
  391.     APCS-R libraries must use OS_CallASWIR12 (R12 being a scratch register
  392.     under APCS-R).
  393.  
  394.  
  395.                       THE CALLASWI MODULE
  396.                       ===================
  397.  
  398. The CallASWI module provides support under RISC OS 3.1, 3.5 and 3.6 for
  399. the following SWIs:
  400.  
  401.               OS_CallASWI
  402.               OS_CallASWIR12
  403.               OS_PlatformFeatures
  404.               OS_SynchroniseCodeAreas
  405.  
  406. This will enable application programmers and library writers to use the
  407. new calls freely without any worries about backwards compatibility. There
  408. is no performance penalty for the use of these SWIs via the CallASWI
  409. module. One slight caveat is that older machines will not know the
  410. _names_ of these SWIs; they would have to be called by number from BASIC.
  411.